package com.jacky.serial;

import com.fazecast.jSerialComm.SerialPort;
import java.util.Enumeration;

public class ListSerialPorts {

    public static void main(String[] args) {
        /*Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
        while (portList.hasMoreElements()) {
            CommPortIdentifier pi = portList.nextElement();
            System.out.println("portName:" + pi.getName() + ",portType:" + pi.getPortType() + ",owner:" + pi.getCurrentOwner());
        }*/
        SerialPort[] serialPorts = SerialPort.getCommPorts();
        for (SerialPort serialPort : serialPorts) {
            System.out.println("发现串口:" + serialPort.getSystemPortName());
        }
    }
}
